<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
<%@include file="/WEB-INF/taglibs/common/taglibs.jsp"%>
<head>
<title>Ship Mode Settings</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link rel="stylesheet" href="<c:url value="/css/styles.css"/>" />
<script src="<c:url value="/javascripts/common.js"/>" type="text/javascript"></script>


</head>

<body><%@include file="../top_menu.jsp"%>
 <table width=100%>
	<tr>
		<td><c:import url="/WEB-INF/jsp/menu/view_orders_menu.jsp" />
		<br />
		</td>
	</tr>
		<tr>
		<td><%@include file="/WEB-INF/jsp/include/messages.jsp"%>
		<br />
		</td>
	</tr>
</table>

 
				<h4>Shipping Mode and Prices</h4>
 <c:if test="${not empty shipModeList}">
		<table width=70% class="formTable">

	<tr class="formHeader">
						<td><b>No #</b></td>
						<td align="center"><b>Shipping Mode</b></td>
						<td align="center"><b>Price</b></td>
						<td align="center"><b>Active</b></td>
						<td align="center"><b>Actions</b></td>
					</tr>
					<c:set var="count" value="1" />
					<c:forEach items="${shipModeList}" var="ship" varStatus="i">
						<tr>
							<td>${count}</td>
							<td>
							<input type="text" id="txtMode_${ship.id}"
								value="${ship.id}" size="50" /></td>
							<td><input type="text" id="txtPrice_${ship.id}"
								value="${ship.price}" size="10" /></td>
							<td><input type="checkbox" id="chkActive_${ship.id}"
								<c:if test="${ship.active}">checked</c:if> /></td>
							<td>&nbsp;&nbsp;&nbsp;&nbsp; <input type="button" class='ui-button ui-state-default ui-corner-all'
								value="Update" onclick="updateShipMode('${ship.id}')" />&nbsp;&nbsp;&nbsp;&nbsp;
							<input type="button" class='ui-button ui-state-default ui-corner-all' value="Delete"
								onclick="deleteShipMode('${ship.id}')" /></td>
						</tr>
						<c:set var="count" value="${count+1}" />
					</c:forEach>
					<tr>
						<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
					</tr></table></c:if>
						<table width=70% class="formTable">

	<tr class="formHeader">
				
						<td colspan="5">Add new ship mode</td>
					</tr>
					<form:form commandName="newShipMode" method="post"
						onsubmit="validateForm()">
						<tr>
							<td>&nbsp;</td>
							<td><form:input path="mode" size="50" /></td>
							<td><form:input path="price" size="10" /></td>
							<td><form:checkbox path="active" /></td>
							<td>&nbsp;&nbsp;&nbsp;&nbsp; <input type=submit value="Save" />&nbsp;&nbsp;&nbsp;&nbsp;
							</td>
						</tr>
					</form:form>
					<tr>
						<td>&nbsp;</td>
					</tr>
				</table>
 

<script language="javascript">
	function updateShipMode(id) {
		if(validate_required(document.getElementById('txtMode_' + id),'Please enter shipping mode name') && 
		 validate_required(document.getElementById('txtPrice_' + id),'Please enter shipping price')){
			var updateUrl = "update_ship_mode.htm?id=" + id;
			updateUrl += "&mode=" + document.getElementById('txtMode_' + id).value;
			updateUrl += "&price=" + document.getElementById('txtPrice_' + id).value;
			updateUrl += "&active=" + document.getElementById('chkActive_' + id).checked;
			window.location = updateUrl;
		}
	}
	
	function deleteShipMode(id) {
		var deleteUrl = "delete_ship_mode.htm?id=" + id;
		window.location = deleteUrl;
	}

	 function validateForm(){
		 return (validate_required(document.getElementById("mode"),'Please enter shipping mode name') && 
		 validate_required(document.getElementById("price"),'Please enter shipping price'));
	 }
</script><%@include file="/WEB-INF/jsp/include/footer.jsp"%>
</body>
</html>